package xjvm_v1.instruction.controltransfer;


import xjvm_v1.instruction.Instruction;
import xjvm_v1.interp.BytecodeReader;
import xjvm_v1.interp.CallSite;
import xjvm_v1.interp.Interpreter;
import xjvm_v1.runtime.*;

public class If_Icmpge implements Instruction {
    @Override
    public void execute(RunTimeEnv runTimeEnv, JThread jThread, MyClass javaClass,
                        CallSite callSite, Interpreter interpreter, BytecodeReader code) {
        JavaFrame javaFrame = jThread.getTopFrame();
        OperandStack operandStack = javaFrame.operandStack;
        LocalVars localVars = javaFrame.localVars;

        int var1 = operandStack.popInt();
        int var0 = operandStack.popInt();
        short offset = code.readU2();
        if(var0 >= var1){
            /*分支*/
            code.pcAddBackOne(offset);
        }else {
            code.pcAdd(2);
        }
    }
}
